﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsTongHopChiTiet
    {
        private string mDiaChiThue = "";
        private string mDienGiai = "";
        private string mKhoa = "";
        private string mKhoaBoPhanCo = "";
        private string mKhoaBoPhanNo = "";
        private string mKhoaChungTu = "";
        private string mKhoaChungTuThamChieu = "";
        private string mKhoaDoiTuongCo = "";
        private string mKhoaDoiTuongNo = "";
        private string mKhoaDoiTuongThue = "";
        private string mKhoaHopDongCo = "";
        private string mKhoaHopDongNo = "";
        private string mKhoaKhoanMucCo = "";
        private string mKhoaKhoanMucNo = "";
        private string mKhoaLoaiThue = "";
        private string mKhoaSanPhamCo = "";
        private string mKhoaSanPhamNo = "";
        private string mKhoaTaiKhoanCo = "";
        private string mKhoaTaiKhoanNo = "";
        private string mKhoaTaiKhoanThue = "";
        private string mLoaiChungTu = "";
        private string mLoaiTien = "";
        private string mMaSoThue = "";
        private string mNgayChungTu = "";
        private string mNgayChungTuThamChieu = "";
        private string mNgayHoaDon = "";
        private string mSoChungTuThamChieu = "";
        private string mSoHoaDon = "";
        private string mSoSeri = "";
        private double mSoTien = 0.0;
        private double mSoTienNT = 0.0;
        private string mTenDoiTuongThue = "";
        private double mTienThue = 0.0;
        private double mTienThueNT = 0.0;
        private double mTyGia = 0.0;
        private int mTyLeThue = 0;
        private string mVe = "";

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM GL_TongHopChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mLoaiChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTienNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTien = Conversions.ToDouble(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetDecimal));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanNo = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongNo = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mKhoaBoPhanNo = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mKhoaSanPhamNo = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHopDongNo = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKhoanMucNo = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanCo = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongCo = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mKhoaBoPhanCo = Conversions.ToString(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetString));
                    this.mKhoaSanPhamCo = Conversions.ToString(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHopDongCo = Conversions.ToString(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKhoanMucCo = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetString));
                    this.mVe = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetString));
                    this.mTenDoiTuongThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetString));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetString));
                    this.mDiaChiThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1a, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1b, modGeneral.typeOfColumn.GetString));
                    this.mTyLeThue = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x1c, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThueNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x1d, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 30, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1f, modGeneral.typeOfColumn.GetString));
                    this.mNgayHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x20, modGeneral.typeOfColumn.GetString));
                    this.mSoSeri = Conversions.ToString(modGeneral.GetValue(dataReader, 0x21, modGeneral.typeOfColumn.GetString));
                    this.mKhoaChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 0x22, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 0x23, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTuThamChieu = Conversions.ToString(modGeneral.GetValue(dataReader, 0x24, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x25];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaChungTu", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTu);
                commandParameters[2] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[3] = DBHelper.createParameter("@LoaiChungTu", DbType.Int64, ParameterDirection.Input, this.mLoaiChungTu);
                commandParameters[4] = DBHelper.createParameter("@LoaiTien", DbType.Int64, ParameterDirection.Input, this.mLoaiTien);
                commandParameters[5] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[6] = DBHelper.createParameter("@SoTienNT", DbType.Date, ParameterDirection.Input, this.mSoTienNT);
                commandParameters[7] = DBHelper.createParameter("@SoTien", DbType.Date, ParameterDirection.Input, this.mSoTien);
                commandParameters[8] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                commandParameters[9] = DBHelper.createParameter("@KhoaTaiKhoanNo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanNo);
                commandParameters[10] = DBHelper.createParameter("@KhoaDoiTuongNo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongNo);
                commandParameters[11] = DBHelper.createParameter("@KhoaBoPhanNo", DbType.Int64, ParameterDirection.Input, this.mKhoaBoPhanNo);
                commandParameters[12] = DBHelper.createParameter("@KhoaSanPhamNo", DbType.Int64, ParameterDirection.Input, this.mKhoaSanPhamNo);
                commandParameters[13] = DBHelper.createParameter("@KhoaHopDongNo", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDongNo);
                commandParameters[14] = DBHelper.createParameter("@KhoaKhoanMucNo", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoanMucNo);
                commandParameters[15] = DBHelper.createParameter("@KhoaTaiKhoanCo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanCo);
                commandParameters[0x10] = DBHelper.createParameter("@KhoaDoiTuongCo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongCo);
                commandParameters[0x11] = DBHelper.createParameter("@KhoaBoPhanCo", DbType.Int64, ParameterDirection.Input, this.mKhoaBoPhanCo);
                commandParameters[0x12] = DBHelper.createParameter("@KhoaSanPhamCo", DbType.Int64, ParameterDirection.Input, this.mKhoaSanPhamCo);
                commandParameters[0x13] = DBHelper.createParameter("@KhoaHopDongCo", DbType.Int64, ParameterDirection.Input, this.mKhoaHopDongCo);
                commandParameters[20] = DBHelper.createParameter("@KhoaKhoanMucCo", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoanMucCo);
                commandParameters[0x15] = DBHelper.createParameter("@KhoaTaiKhoanThue", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanThue);
                commandParameters[0x16] = DBHelper.createParameter("@Ve", DbType.Int64, ParameterDirection.Input, this.mVe);
                commandParameters[0x17] = DBHelper.createParameter("@KhoaDoiTuongThue", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongThue);
                commandParameters[0x18] = DBHelper.createParameter("@TenDoiTuongThue", DbType.Int64, ParameterDirection.Input, this.mTenDoiTuongThue);
                commandParameters[0x19] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[0x1a] = DBHelper.createParameter("@DiaChiThue", DbType.Int64, ParameterDirection.Input, this.mDiaChiThue);
                commandParameters[0x1b] = DBHelper.createParameter("@KhoaLoaiThue", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiThue);
                commandParameters[0x1c] = DBHelper.createParameter("@TyLeThue", DbType.Double, ParameterDirection.Input, this.mTyLeThue);
                commandParameters[0x1d] = DBHelper.createParameter("@TienThueNT", DbType.Date, ParameterDirection.Input, this.mTienThueNT);
                commandParameters[30] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[0x1f] = DBHelper.createParameter("@SoHoaDon", DbType.Int64, ParameterDirection.Input, this.mSoHoaDon);
                commandParameters[0x20] = DBHelper.createParameter("@NgayHoaDon", DbType.Int64, ParameterDirection.Input, this.mNgayHoaDon);
                commandParameters[0x21] = DBHelper.createParameter("@SoSeri", DbType.Int64, ParameterDirection.Input, this.mSoSeri);
                commandParameters[0x22] = DBHelper.createParameter("@KhoaChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mKhoaChungTuThamChieu);
                commandParameters[0x23] = DBHelper.createParameter("@SoChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mSoChungTuThamChieu);
                commandParameters[0x24] = DBHelper.createParameter("@NgayChungTuThamChieu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTuThamChieu);
                flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_TongHopChiTiet", commandParameters) > 0;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public void SetBlank()
        {
            this.mKhoa = "";
            this.mKhoaChungTu = "";
            this.mNgayChungTu = "";
            this.mLoaiChungTu = "";
            this.mLoaiTien = "";
            this.mTyGia = 0.0;
            this.mSoTienNT = 0.0;
            this.mSoTien = 0.0;
            this.mDienGiai = "";
            this.mKhoaTaiKhoanNo = "";
            this.mKhoaDoiTuongNo = "";
            this.mKhoaBoPhanNo = "";
            this.mKhoaSanPhamNo = "";
            this.mKhoaHopDongNo = "";
            this.mKhoaKhoanMucNo = "";
            this.mKhoaTaiKhoanCo = "";
            this.mKhoaDoiTuongCo = "";
            this.mKhoaBoPhanCo = "";
            this.mKhoaSanPhamCo = "";
            this.mKhoaHopDongCo = "";
            this.mKhoaKhoanMucCo = "";
            this.mKhoaTaiKhoanThue = "";
            this.mVe = "";
            this.mKhoaDoiTuongThue = "";
            this.mTenDoiTuongThue = "";
            this.mMaSoThue = "";
            this.mDiaChiThue = "";
            this.mKhoaLoaiThue = "";
            this.mTyLeThue = 0;
            this.mTienThueNT = 0.0;
            this.mTienThue = 0.0;
            this.mSoHoaDon = "";
            this.mNgayHoaDon = "";
            this.mSoSeri = "";
            this.mKhoaChungTuThamChieu = "";
            this.mSoChungTuThamChieu = "";
            this.mNgayChungTuThamChieu = "";
        }

        public string DiaChiThue
        {
            get
            {
                return this.mDiaChiThue;
            }
            set
            {
                this.mDiaChiThue = value;
            }
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaBoPhanCo
        {
            get
            {
                return this.mKhoaBoPhanCo;
            }
            set
            {
                this.mKhoaBoPhanCo = value;
            }
        }

        public string KhoaBoPhanNo
        {
            get
            {
                return this.mKhoaBoPhanNo;
            }
            set
            {
                this.mKhoaBoPhanNo = value;
            }
        }

        public string KhoaChungTu
        {
            get
            {
                return this.mKhoaChungTu;
            }
            set
            {
                this.mKhoaChungTu = value;
            }
        }

        public string KhoaChungTuThamChieu
        {
            get
            {
                return this.mKhoaChungTuThamChieu;
            }
            set
            {
                this.mKhoaChungTuThamChieu = value;
            }
        }

        public string KhoaDoiTuongCo
        {
            get
            {
                return this.mKhoaDoiTuongCo;
            }
            set
            {
                this.mKhoaDoiTuongCo = value;
            }
        }

        public string KhoaDoiTuongNo
        {
            get
            {
                return this.mKhoaDoiTuongNo;
            }
            set
            {
                this.mKhoaDoiTuongNo = value;
            }
        }

        public string KhoaDoiTuongThue
        {
            get
            {
                return this.mKhoaDoiTuongThue;
            }
            set
            {
                this.mKhoaDoiTuongThue = value;
            }
        }

        public string KhoaHopDongCo
        {
            get
            {
                return this.mKhoaHopDongCo;
            }
            set
            {
                this.mKhoaHopDongCo = value;
            }
        }

        public string KhoaHopDongNo
        {
            get
            {
                return this.mKhoaHopDongNo;
            }
            set
            {
                this.mKhoaHopDongNo = value;
            }
        }

        public string KhoaKhoanMucCo
        {
            get
            {
                return this.mKhoaKhoanMucCo;
            }
            set
            {
                this.mKhoaKhoanMucCo = value;
            }
        }

        public string KhoaKhoanMucNo
        {
            get
            {
                return this.mKhoaKhoanMucNo;
            }
            set
            {
                this.mKhoaKhoanMucNo = value;
            }
        }

        public string KhoaLoaiThue
        {
            get
            {
                return this.mKhoaLoaiThue;
            }
            set
            {
                this.mKhoaLoaiThue = value;
            }
        }

        public string KhoaSanPhamCo
        {
            get
            {
                return this.mKhoaSanPhamCo;
            }
            set
            {
                this.mKhoaSanPhamCo = value;
            }
        }

        public string KhoaSanPhamNo
        {
            get
            {
                return this.mKhoaSanPhamNo;
            }
            set
            {
                this.mKhoaSanPhamNo = value;
            }
        }

        public string KhoaTaiKhoanCo
        {
            get
            {
                return this.mKhoaTaiKhoanCo;
            }
            set
            {
                this.mKhoaTaiKhoanCo = value;
            }
        }

        public string KhoaTaiKhoanNo
        {
            get
            {
                return this.mKhoaTaiKhoanNo;
            }
            set
            {
                this.mKhoaTaiKhoanNo = value;
            }
        }

        public string KhoaTaiKhoanThue
        {
            get
            {
                return this.mKhoaTaiKhoanThue;
            }
            set
            {
                this.mKhoaTaiKhoanThue = value;
            }
        }

        public string LoaiChungTu
        {
            get
            {
                return this.mLoaiChungTu;
            }
            set
            {
                this.mLoaiChungTu = value;
            }
        }

        public string LoaiTien
        {
            get
            {
                return this.mLoaiTien;
            }
            set
            {
                this.mLoaiTien = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string NgayChungTuThamChieu
        {
            get
            {
                return this.mNgayChungTuThamChieu;
            }
            set
            {
                this.mNgayChungTuThamChieu = value;
            }
        }

        public string NgayHoaDon
        {
            get
            {
                return this.mNgayHoaDon;
            }
            set
            {
                this.mNgayHoaDon = value;
            }
        }

        public string SoChungTuThamChieu
        {
            get
            {
                return this.mSoChungTuThamChieu;
            }
            set
            {
                this.mSoChungTuThamChieu = value;
            }
        }

        public string SoHoaDon
        {
            get
            {
                return this.mSoHoaDon;
            }
            set
            {
                this.mSoHoaDon = value;
            }
        }

        public string SoSeri
        {
            get
            {
                return this.mSoSeri;
            }
            set
            {
                this.mSoSeri = value;
            }
        }

        public double SoTien
        {
            get
            {
                return this.mSoTien;
            }
            set
            {
                this.mSoTien = value;
            }
        }

        public double SoTienNT
        {
            get
            {
                return this.mSoTienNT;
            }
            set
            {
                this.mSoTienNT = value;
            }
        }

        public string TenDoiTuongThue
        {
            get
            {
                return this.mTenDoiTuongThue;
            }
            set
            {
                this.mTenDoiTuongThue = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public double TienThueNT
        {
            get
            {
                return this.mTienThueNT;
            }
            set
            {
                this.mTienThueNT = value;
            }
        }

        public double TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }

        public int TyLeThue
        {
            get
            {
                return this.mTyLeThue;
            }
            set
            {
                this.mTyLeThue = value;
            }
        }

        public string Ve
        {
            get
            {
                return this.mVe;
            }
            set
            {
                this.mVe = value;
            }
        }
    }
}

